Skip to content

Conversation

@lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Nov 20, 2025

closes #149083

Fixes the ICE when using async fn inside const impl blocks by adding AST validation.

Currently, inherent impls does not perform any checks to verify whether it contains async fn declarations. In this PR, I have modified the visit_assoc_item function to call check_async_fn_in_const_trait_or_impl within the TraitOrImpl::Impl case to handle this requirement. Additionally, this change has introduced three possible contexts for the corresponding error messages, so I have updated to properly distinguish between these different contexts when generating messages.

r? oli-obk

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Nov 20, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 20, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@oli-obk
Copy link
Contributor

oli-obk commented Nov 20, 2025

Awesome! Thanks for the quick fix

@bors r+ rollup

@bors
Copy link
Collaborator

bors commented Nov 20, 2025

📌 Commit c108451 has been approved by oli-obk

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 20, 2025
bors added a commit that referenced this pull request Nov 20, 2025
Rollup of 9 pull requests

Successful merges:

 - #149033 (autodiff rlib handling)
 - #149088 (Add missing trailing period to RustDoc for fn create_dir().)
 - #149111 (fs: Run file lock tests on all platforms that support it)
 - #149113 (sgx: avoid unnecessarily creating a slice)
 - #149123 (std: sys: fs: uefi: Fix FileAttr size)
 - #149133 (Remove an unused variable)
 - #149139 (Enable host tools for aarch64-unknown-linux-ohos)
 - #149144 (Reject `async fn` in `const impl` during AST validation)
 - #149154 (Fix platform supports docs tiny typo)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 83e37a9 into rust-lang:main Nov 21, 2025
11 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 21, 2025
rust-timer added a commit that referenced this pull request Nov 21, 2025
Rollup merge of #149144 - lapla-cogito:ice_149083, r=oli-obk

Reject `async fn` in `const impl` during AST validation

closes #149083

Fixes the ICE when using `async fn` inside `const impl` blocks by adding AST validation.

Currently, inherent `impl`s does not perform any checks to verify whether it contains `async fn` declarations. In this PR, I have modified the `visit_assoc_item` function to call `check_async_fn_in_const_trait_or_impl` within the `TraitOrImpl::Impl` case to handle this requirement. Additionally, this change has introduced three possible contexts for the corresponding error messages, so I have updated to properly distinguish between these different contexts when generating messages.

r? oli-obk
@lapla-cogito lapla-cogito deleted the ice_149083 branch November 21, 2025 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ICE async functions cannot be const fn

5 participants